/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.pizzaria.view;

import br.com.pizzaria.util.Backup;
import br.com.pizzaria.util.GeneratorPDF;
import br.com.pizzaria.util.Global;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.Timer;

/**
 *
 * @author Jaime
 */
public class MenuAjuda extends javax.swing.JInternalFrame {

    SobreView sobreV;

    /**
     * Creates new form MenuProdução
     */
    public MenuAjuda() {
        initComponents();
        Timer time = new Timer(1000, ativar);
        time.start();

        btnSobre.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.CTRL_DOWN_MASK), "evento");
        btnSobre.getActionMap().put("evento", new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
                btnSobreActionPerformed(e);
            }

        });
        btnSobre1.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.CTRL_DOWN_MASK), "evento");
        btnSobre1.getActionMap().put("evento", new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
                btnSobre1ActionPerformed(e);
            }

        });
        btnSobre2.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK), "evento");
        btnSobre2.getActionMap().put("evento", new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
                btnSobre2ActionPerformed(e);
            }

        });

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnSobre = new javax.swing.JButton();
        btnSobre1 = new javax.swing.JButton();
        btnSobre2 = new javax.swing.JButton();

        setTitle("Menu Ajuda");
        setPreferredSize(new java.awt.Dimension(308, 263));

        btnSobre.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnSobre.setForeground(new java.awt.Color(0, 51, 255));
        btnSobre.setText("<html>Sobre <font size='2' style='color:black'> Crtl-1 </font>");
        btnSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSobreActionPerformed(evt);
            }
        });

        btnSobre1.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnSobre1.setForeground(new java.awt.Color(0, 51, 255));
        btnSobre1.setText("<html>Gerar Backup <font size='2' style='color:black'> Crtl-2 </font>");
        btnSobre1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSobre1ActionPerformed(evt);
            }
        });

        btnSobre2.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnSobre2.setForeground(new java.awt.Color(0, 51, 255));
        btnSobre2.setText("<html>Manual do Usuário <font size='2' style='color:black'> Crtl-3 </font>");
        btnSobre2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSobre2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnSobre, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
                    .addComponent(btnSobre1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
                    .addComponent(btnSobre2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnSobre, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnSobre1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnSobre2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSobreActionPerformed
        // TODO add your handling code here:
        if (sobreV == null || !sobreV.isShowing()) {
            sobreV = new SobreView();
            sobreV.setVisible(true);
        }
    }//GEN-LAST:event_btnSobreActionPerformed

    private void btnSobre1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSobre1ActionPerformed
        // TODO add your handling code here:

        JOptionPane.showMessageDialog(null, Backup.gerarBackup());

    }//GEN-LAST:event_btnSobre1ActionPerformed

    private void btnSobre2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSobre2ActionPerformed
        // TODO add your handling code here:
        String path = System.getProperty("user.dir") + "\\Manual\\Manual.pdf";
        GeneratorPDF.abrirPdf(path);
    }//GEN-LAST:event_btnSobre2ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSobre;
    private javax.swing.JButton btnSobre1;
    private javax.swing.JButton btnSobre2;
    // End of variables declaration//GEN-END:variables
    ActionListener ativar = (new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            centralizarComponente();
        }

    });

    public final void centralizarComponente() {
        int x = Global.principal.getLocation().x;
        int y = Global.principal.getLocation().y;

        Dimension ds = Global.principal.getSize();
        Dimension dw = getSize();
        setLocation((0), (0));
    }
}
